home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Write WP info *)
- (* *)
- (* Copyright 1988, 1989, 1990 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- UNIT BBWP;
-
- INTERFACE
-
- FUNCTION wp_write : BOOLEAN;
-
- CONST
- wp_write_file_name = 'WP.OUT';
-
- IMPLEMENTATION
-
- USES
- bbdummy,
- bbmdata,
- bbmess,
- bbmisc5,
- bbrunerr,
- bbsdata,
- bbsema2,
- bbtask,
- bbtime,
- bbuf;
-
- (*===========================================================================*)
- (* WP_WRITE *)
- (*===========================================================================*)
-
- FUNCTION wp_write : BOOLEAN;
-
- VAR
- exp_date : LONGINT;
- first_one : BOOLEAN;
- i : INTEGER;
- loop_count : BYTE;
- op_tcb : tcb_ptr;
- uid_buffer : user_record_type;
- u_i_ptr : user_index_ptr;
- wp_file : TEXT;
-
- PROCEDURE wp_start_write;
- VAR
- io_result : INTEGER;
- startup_sw : BOOLEAN;
-
- BEGIN;
-
- ASSIGN(wp_file, wp_write_file_name);
-
- {$I-}
- APPEND(wp_file);
- io_result := IORESULT;
- {$I+}
- startup_sw := io_result <> dos_ok;
-
- IF startup_sw THEN
- BEGIN;
-
- {$I-}
- REWRITE(wp_file);
- io_result := IORESULT;
- {$I+}
-
- END;
-
- IF io_result <> dos_ok THEN
- BEGIN;
- send_tnc_data_str(dos_err_message(i) + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF startup_sw THEN
- BEGIN;
- WRITELN(wp_file, 'SP WPAGE @ ', opt_block.wp_bb_sign);
- WRITELN(wp_file, 'WP auto-update');
- END;
-
- END;
-
- PROCEDURE wp_write_data(uid : user_record_ptr);
- VAR
- s : STRING;
-
- BEGIN;
-
- (*---------------------------------------------------------------------*)
- (* Compute Home BBS. Add "H" address if it is us *)
- (*---------------------------------------------------------------------*)
-
- s := uid^.user_bbs;
- IF (s = opt_block.this_bb_sign) OR (s = opt_block.this_bb_addr) THEN
- s := s + opt_block.this_bb_h;
-
- (*---------------------------------------------------------------------*)
- (* Put out various times *)
- (*---------------------------------------------------------------------*)
-
- s := s + ' On ' + COPY(time_str(uid^.user_n_time, TRUE), 1, 6)
- + ' Expires ' + COPY(time_str(exp_date, TRUE), 1, 6);
-
- (*---------------------------------------------------------------------*)
- (* Name and Zip if they are here *)
- (*---------------------------------------------------------------------*)
-
- IF uid^.user_name <> '' THEN
- s := s + ' Name ' + uid^.user_name;
-
- IF uid^.user_zip <> '' THEN
- s := s + ' Zip ' + uid^.user_zip;
-
- (*---------------------------------------------------------------------*)
- (* Write the line out *)
- (*---------------------------------------------------------------------*)
-
- WRITELN(wp_file, uid^.user_id, ' QTH ', s);
-
- END;
-
- FUNCTION check_uid(uid : user_record_ptr) : BOOLEAN;
-
- BEGIN
-
- (*---------------------------------------------------------------------*)
- (* Assume user not to be written *)
- (*---------------------------------------------------------------------*)
-
- check_uid := FALSE;
-
- (*---------------------------------------------------------------------*)
- (* Must have a BBS *)
- (*---------------------------------------------------------------------*)
-
- IF uid^.user_bbs = '' THEN EXIT;
-
- (*---------------------------------------------------------------------*)
- (* Must have changed *)
- (*---------------------------------------------------------------------*)
-
- IF (uid^.user_flag AND user_f_adrchg) = 0 THEN
- EXIT;
-
- (*---------------------------------------------------------------------*)
- (* Must have a current date *)
- (*---------------------------------------------------------------------*)
-
- exp_date := uid^.user_n_time + opt_block.home_expires;
- IF exp_date < (current_day_time + 28) THEN
- EXIT;
-
- (*---------------------------------------------------------------------*)
- (* SUCCESS!!! *)
- (*---------------------------------------------------------------------*)
-
- check_uid := TRUE;
-
- END;
-
- (*=========================================================================*)
- (* Main line *)
- (*=========================================================================*)
-
- BEGIN;
-
- wp_write := FALSE;
-
- (*-----------------------------------------------------------------------*)
- (* If no place to send it, then leave *)
- (*-----------------------------------------------------------------------*)
-
- IF opt_block.wp_bb_sign = '' THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Tell SYSOP what is happening *)
- (*-----------------------------------------------------------------------*)
-
- send_tnc_data_str('WP update message processing started' + cr);
-
- (*-----------------------------------------------------------------------*)
- (* Find operator's TCB *)
- (*-----------------------------------------------------------------------*)
-
- op_tcb := main_tcb^.next_tcb;
-
- WHILE (op_tcb^.tcb_type <> th_operator) AND (op_tcb <> main_tcb) DO
- op_tcb := op_tcb^.next_tcb;
-
- IF op_tcb = main_tcb THEN
- BEGIN;
- WRITELN('*****');
- WRITELN('WP processing could not find operator');
- WRITELN('*****');
- HALT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Loop thru user records looking for WP work to do *)
- (*-----------------------------------------------------------------------*)
-
- first_one := TRUE;
- loop_count := 20;
-
- u_i_ptr := uid_chain;
-
- WHILE u_i_ptr <> NIL DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Fetch the user *)
- (*-------------------------------------------------------------------*)
-
- uid_buffer := get_uid(u_i_ptr)^;
-
- (*-------------------------------------------------------------------*)
- (* See if this applies *)
- (*-------------------------------------------------------------------*)
-
- IF check_uid(@uid_buffer) THEN
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* Write this user out *)
- (*---------------------------------------------------------------*)
-
- (*---------------------------------------------------------------*)
- (* Is this the first user to be written out. If so, start things*)
- (*---------------------------------------------------------------*)
-
- IF first_one THEN
- BEGIN;
- wp_start_write;
- IF active_tcb^.error_sw THEN EXIT;
- first_one := FALSE;
- wp_write := TRUE;
- END;
-
- (*---------------------------------------------------------------*)
- (* Tell SYSOP what is happening *)
- (*---------------------------------------------------------------*)
-
- send_tnc_data_str('WP update for ' + uid_buffer.user_id + cr);
-
- (*---------------------------------------------------------------*)
- (* Write the data out *)
- (*---------------------------------------------------------------*)
-
- wp_write_data(@uid_buffer);
- IF active_tcb^.error_sw THEN EXIT;
-
- (*---------------------------------------------------------------*)
- (* Turn off the flag so we don't do this again. *)
- (*---------------------------------------------------------------*)
-
- uid_buffer.user_flag :=
- uid_buffer.user_flag AND (NOT user_f_adrchg);
-
- (*---------------------------------------------------------------*)
- (* Write the user data back into the info file *)
- (*---------------------------------------------------------------*)
-
- update_uid(@uid_buffer);
-
- (*---------------------------------------------------------------*)
- (* Catch the special case of the local SYSOP *)
- (*---------------------------------------------------------------*)
-
- IF uid_buffer.user_i_ptr = op_tcb^.uid_data.user_i_ptr THEN
- op_tcb^.uid_data.user_flag :=
- op_tcb^.uid_data.user_flag AND (NOT user_f_adrchg);
-
- END; (*----- End handling a user to do ----------------------------*)
-
- u_i_ptr := u_i_ptr^.user_next;
-
- IF loop_count > 0 THEN
- DEC(loop_count)
- ELSE
- BEGIN;
- loop_count := 20;
- task_switch;
- END;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* If nothing happened then exit *)
- (*-----------------------------------------------------------------------*)
-
- IF first_one THEN
- BEGIN;
- send_message(message_action_complete);
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Obtain the interrupt lock *)
- (*-----------------------------------------------------------------------*)
-
- get_semaphore(semaphore_interrupts, sem_exclusive, FALSE);
-
- (*-----------------------------------------------------------------------*)
- (* Close up *)
- (*-----------------------------------------------------------------------*)
-
- CLOSE(wp_file);
-
- (*-----------------------------------------------------------------------*)
- (* Release the interrupt lock *)
- (*-----------------------------------------------------------------------*)
-
- free_semaphore(semaphore_interrupts);
-
- (*-----------------------------------------------------------------------*)
- (* Tell user *)
- (*-----------------------------------------------------------------------*)
-
- send_message(message_action_complete);
-
- END;
-
- END.
-